<template>
  <div class="searchForm">
    <div class="form-Container">
      <el-form ref="searchRef" class="searchList" :model="search">
        <div v-for="(item, index) in formData" :key="index">
          <el-form-item
            v-if="item.type == 'input'"
            :prop="item.model"
            :label="item.label"
            label-width="120px">
            <el-input
              style="width: 150px; height: 28px !important"
              v-model="search[item.model]"
              :placeholder="item.placeholder || item.label"
              :clearable="item.clearable" />
          </el-form-item>
        </div>
      </el-form>
    </div>
    <div class="form-footer">
      <el-button type="primary" size="small" icon="el-icon-search" @click="searchHandle"
        >查询</el-button
      >
      <el-button type="default" size="small" icon="el-icon-refresh" @click="searchReset"
        >重置</el-button
      >
    </div>
  </div>
</template>

<script>
export default {
  props: {
    formData: {
      type: Array,
      default: () => [],
    },
    search: {
      type: Object,
      default: () => {},
    },
  },
  data() {
    return {};
  },
  methods: {
    searchHandle() {
      this.$emit("searchHandle");
    },
    searchReset() {
      this.$refs.searchRef.resetFields();
      this.$emit("searchReset");
    },
  },
};
</script>

<style lang="less" scoped>
.searchForm {
  display: flex;
  flex-direction: column;
  margin: 10px 20px;
  border: 1px solid #ddd;

  .form-Container {
    flex: 1;
    padding: 0 10px;

    .searchList {
      display: flex;
      flex-wrap: wrap;
    }
  }

  .form-footer {
    width: 100%;
    padding: 10px;
    display: flex;
    justify-content: center;
  }
}
/deep/ .el-input__inner {
  height: 28px;
  font-size: 12px;
}
/deep/.el-form-item {
  .el-form-item__label {
    width: 120px !important;
    text-align: right;
  }
}
</style>
